package com.dianrui.qiyouriding.adapter;

import android.content.Context;
import android.graphics.Color;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.dianrui.qiyouriding.R;
import com.dianrui.qiyouriding.bean.TopUp;

import java.util.List;

public class TopUpAdapter extends BaseQuickAdapter<TopUp, BaseViewHolder> {
    private Context mContext;
    private ItemSelectedCallBack mCallBack;


    public TopUpAdapter(Context mContext, List<TopUp> list) {
        super(R.layout.item_top_up,list);
        this.mContext = mContext;
    }

    @Override
    protected void convert(BaseViewHolder helper, TopUp item) {
        helper.setText(R.id.money,item.money+"元");
        helper.setText(R.id.subject,item.subject);
        if (item.is_check==1){
            helper.setBackgroundRes(R.id.main_topup,R.drawable.bg_recharge_select);
            helper.setTextColor(R.id.money, Color.BLACK);
            helper.setTextColor(R.id.subject, Color.BLACK);
        } else {
            helper.setBackgroundRes(R.id.main_topup,R.drawable.bg_recharge_select_un);
            helper.setTextColor(R.id.money, Color.BLACK);
            helper.setTextColor(R.id.subject, Color.BLACK);
        }
        if (mCallBack != null) {
            mCallBack.convert(helper, helper.getLayoutPosition());
        }


    }

    public void setItemSelectedCallBack(ItemSelectedCallBack CallBack) {
        this.mCallBack = CallBack;
    }

    public interface ItemSelectedCallBack {
        void convert(BaseViewHolder holder, int position);

    }
}
